<?	
	$db['1']['pass'] = $pg_password; //"w9JwRoA";
	$db['1']['user'] = $pg_username; //"root";
	$db['1']['name'] = $pg_db; //"rp2";
	$db['1']['host'] = $pg_host; //"209.25.134.5";

	if(!$dbh2)
		$dbh2 = pg_connect("dbname=".$db[1][name]." host=".$db[1][host]." user=".$db[1][user]." password=".$db[1][pass]."");
	
	//$id
	$qq = "select product_id,type,name from products where reseller_id='$id'";
	if($result = pg_query($dbh2,$qq)){
		while($row = pg_fetch_assoc($result)){
			$products[] = $row;
		}
	}else return 0;

	
	$product_off=Array();
	if($has_domain){
		if(is_array($products)) foreach($products as $p){
			if($p[type]=='domain'){
				$product_off[domains_offering][ $p[product_id]] = $has_domain;
			}
		}
	}
	if(is_array($products)) reset($products);
	if(is_array($products)) foreach($products as $p){
		if($p[type]=='plan'){
			foreach($plans as $plan){
				if(strtolower($p[name]) == strtolower($plan[plan])){
					if($plan[offering]){
						$product_off[plans_offering][$p[product_id]] = $plan[offering];
						$product_off[plans_on_index][$p[product_id]] = $plan[display_on_index];
						if($has_domain_inplan)
							$product_off[domains_free][$p[product_id]][12] = $has_domain_inplan;
						$product_off[periods][$p[product_id]][12] = $plan[offering];
					}
					
					
				}
			}
		}else
		if($p[type]=='service'){
       $product_off[services_offering][$p[product_id]] = 'on';
    }

	}
	$qq= "update stores set products='".base64_encode(serialize($product_off))."' where reseller_id='$id'";
	$result = pg_query($dbh2,$qq);
		
?>
